package com.xiguthings.waka.service.papercard.impl;

import com.xiguthings.waka.dao.mapper.PaperCardMapper;
import com.xiguthings.waka.exception.BussinessException;
import com.xiguthings.waka.po.PaperCard;
import com.xiguthings.waka.po.PaperCardExample;
import com.xiguthings.waka.po.extpo.Page;
import com.xiguthings.waka.publicUtils.StringUtils;
import com.xiguthings.waka.service.papercard.IPaperCardService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class PaperCardServiceImpl implements IPaperCardService {
    @Resource
    PaperCardMapper paperCardMapper;

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public int countByExample(PaperCardExample paperCardExample) throws Exception {
        // TODO
        return 0;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int deleteByExample(PaperCardExample paperCardExample) throws Exception {
        // TODO
        return 0;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int deleteByPrimaryKey(String id) throws Exception {

        return paperCardMapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int insert(PaperCard paperCard) throws Exception {
        if (paperCard == null) {
            BussinessException.throwThis(CODE_EMPTY_REQUIRED, null);
        }

        String id = StringUtils.getRandomUUID();
        paperCard.setPaperCardId(id);
        int row = paperCardMapper.insert(paperCard);
        return row;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int insertSelective(PaperCard paperCard) throws Exception {
        return 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public List<PaperCard> selectByExample(PaperCardExample paperCardExample) throws Exception {
        return paperCardMapper.selectByExample(paperCardExample);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public PaperCard selectByPrimaryKey(String id) throws Exception {

        return paperCardMapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int updateByExampleSelective(PaperCard paperCard, PaperCardExample paperCardExample) throws Exception {
        // TODO
        return 0;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int updateByExample(PaperCard paperCard, PaperCardExample paperCardExample) throws Exception {
        // TODO
        return 0;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int updateByPrimaryKeySelective(PaperCard paperCard) throws Exception {

        return paperCardMapper.updateByPrimaryKeySelective(paperCard);
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int updateByPrimaryKey(PaperCard paperCard) throws Exception {
        // TODO
        return 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public Page selectByPage(Page pageEntity, PaperCardExample paperCardExample) throws Exception {
        // TODO
        return null;
    }
}
